import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.SocketTimeoutException;



public class Servidor extends Thread {
	private ServerSocket server;
	private final int PORT = 7920;
	private final int COLA = 10;
	boolean running;
	
	public void run() {
		running = true;
		iniciarServer();
	    aceptarCliente();
	    
	}
	
	public void setRunning(boolean b) {
		this.running = b;
	}

	private void aceptarCliente() {
	  	try {
    		while(running){
    			InnerServer innerServer = new InnerServer(server.accept());
    			innerServer.start();
    		}
    	} catch (IOException e) {
    		e.printStackTrace();
    		System.exit(1);
    	}   
	}

	private void iniciarServer() {
		try {
    		server = new ServerSocket(PORT, COLA);
   	
    	} catch (IOException e) {
    		e.printStackTrace();
    		System.exit(1);
    	} 
		
	}
	

	
	
	
}
